package nc.bs.arap.selectedpay;
import java.util.Hashtable;
import java.util.Vector;

import nc.vo.arap.exception.ExceptionHandler;
import nc.vo.arap.selectedpay.XzfkVO;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBItemVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
public class CheckBO {
  public CheckBO() {
  }

  public Hashtable canSave(Vector vo) throws BusinessException
 {
   Hashtable result=new Hashtable();
   DJZBItemVO[] vos=new DJZBItemVO[vo.size()];
   vo.copyInto(vos);
   try
   {
     BillFilterDMO dmo=new BillFilterDMO();
     dmo.canSave(vos);

   }
   catch(Exception e)
    {
	   throw ExceptionHandler.handleException(this.getClass(),e);
    }
   return result;
 }
  
  public void checkSaveYe(DJZBVO source) throws BusinessException
  {
	  try
	  {
		 
		  DJZBItemVO[] item=(DJZBItemVO[])source.getChildrenVO();
		  DJZBHeaderVO header=(DJZBHeaderVO)source.getParentVO();
		  String tsvouchid=header.getVouchid();
		  BillFilterDMO dmo=new BillFilterDMO();
		  Vector<XzfkVO> save=new Vector<XzfkVO>();
		  for(int i=0;i<item.length;i++)
		  {
			  Hashtable<String,UFDouble> s=item[i].source;
			  if(s==null)
				  continue;
			  Vector temp=dmo.checkYe(s);
			  for(int j=0;j<temp.size();j++)
			  {
				  XzfkVO vo=(XzfkVO)temp.get(j);
				  vo.setTvouchid(tsvouchid);
				  vo.setTfb_oid(item[i].getFb_oid());
				  save.add(vo);
			  }
		  } 
		  XzfkVO[] vos=new XzfkVO[save.size()];
		  save.copyInto(vos);
		  dmo.saveXzfk(vos);
	  }
	  catch(Exception e)
	  {
		  throw ExceptionHandler.handleException(this.getClass(),e);
	  }
  }

}
